# $Id: PKGBUILD 86676 2013-03-21 01:52:51Z eric $
# Maintainer: Ronald van Haren <ronald.archlinux.org>
# Contributor: Claudio Riva <firetux83@gmail.com>

pkgname=emesene
pkgver=2.12.9
pkgrel=2
pkgdesc="A pygtk MSN Messenger client"
url="http://www.emesene.org/"
license=('GPL' 'GPL3' 'LGPL3')
arch=('any') 
depends=('python2' 'pygtk' 'python2-dnspython' 'pylint' 'python2-notify' 'openssl' \
'python2-imaging' 'dbus-python' 'xdg-utils' 'hicolor-icon-theme' \
'gstreamer0.10-python' 'gstreamer0.10-good' 'pycrypto' \
'python2-gobject2' 'python2-pyopenssl' 'pywebkitgtk')
makedepends=('python2-distribute')
optdepends=('gnome-python-extras: spell-check plugin'
	'gtkspell: spell-check plugin'
	'farsight2: webcam support'
        'xmpppy: for gtalk and facebook chat support'
	'python2-pyqt: alternative qt4 interface (emesene -e main:qt4_main')
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/emesene/emesene/tarball/v${pkgver}"
        'emesene.run')
install=emesene.install
options=('!libtool')
sha1sums=('a1cd8aee7affae8f2637df65e2d45a06d3298f7a'
          '2bd13ada86aa0af6307a41047f0d7caf2995660d')

package() {
  cd "${srcdir}"/${pkgname}-${pkgname}-b89aa5e

  # do not import dummy session
  # sed -i -e  "/import dummy/d" emesene/emesene.py

  # fix version number
#  sed -i 's|2.12.2-devel|2.12.3|' setup.py

  # install files
  export PYTHONPATH="${pkgdir}/usr/lib/python2.7/site-packages/"
  install -d "${pkgdir}"/usr/lib/python2.7/site-packages/
  python2 setup.py install --prefix="${pkgdir}"/usr

  cd "${pkgdir}"
  # use /usr/share/emesene instead of /usr/lib/python2.7/site-packages
  mv -f "${pkgdir}"/usr/lib/python2.7/site-packages/emesene-${pkgver}-py2.7.egg/share \
        "${pkgdir}"/usr
  mv -f "${pkgdir}"/usr/lib/python2.7/site-packages/emesene-${pkgver}-py2.7.egg/emesene \
        "${pkgdir}"/usr/share
  rm -rf "${pkgdir}"/usr/lib

  # python -> python2 
  find -name *.py -exec sed -i "s|/usr/bin/env python|/usr/bin/env python2|" {} \;
  sed -i "s|/usr/bin/env python|/usr/bin/env python2|" "${pkgdir}"/usr/share/emesene/emesene

  # create executable
  install -Dm755 "${srcdir}"/emesene.run "${pkgdir}"/usr/bin/emesene
}
